<template>
	<view class="qxlj_back4 contain">
		<view class="strategy_box" v-for="(item,index) in glList" :key="index"
			@click="goDetail(item.LinkUrl)">
			<view class="right">
				<image :src="item.CoverImg" mode=""></image>
			</view>
			<view class="left qxlj_back2">
				<view class="one">{{item.Abstract}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getChildren,
	} from '@/api/homePage.js';
	export default {
		data() {
			return {
				glList: '',
			}
		},
		onLoad() {
			this.getGLDate();
		},
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
			return {
				title: this.$category.appName, //分享的名称
				path: '/pages/index/strategyList',
				mpId: this.$category.appid //此处配置微信小程序的AppId
			}
		},
		methods: {
			goDetail(e) {
				if (e.includes('http') || e.includes('https')) {
					uni.navigateTo({
						url: '/pages/webView/webView?url=' + e
					})
					return;
				}
				if (e.includes('pages/')) {
					uni.navigateTo({
						url: e
					})
					return;
				};
			},
			//日期转换
			timestampToTimeYMD(timestamp) {
				var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var Y = date.getFullYear() + '-';
				var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate());
				return Y + M + D;
			},
			//获取攻略数据
			async getGLDate() {
				uni.showLoading({});
				try {
					const Data = await getChildren({
						ArticleCategoryId: 3396,
						Index: 1,
						Size: 100,
					})
					uni.hideLoading();
					console.log(Data.Data)
					Data.Data.forEach(con => {
						con.AddTime = this.timestampToTimeYMD(con.AddTime);
					})
					this.glList = Data.Data;
				} catch (e) {

				}
			},
		},
	}
</script>

<style scoped lang="scss">
	.contain {
		width: 100%;
		min-height: 100vh;
		padding: 4%;
		padding-top: 2%;
	}

	.strategy_box {
		width: 100%;
		height: 180px;
		display: flex;
		margin-top: 2%;
		justify-content: space-between;
		flex-direction: column;
		position: relative;

		.right {
			width: 100%;
			height: 120px;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.left {
			width: 100%;
			height: 60px;
			padding: 2% 4%;

			.one {
				color: #000000;
				font-size: 16px;
				font-weight: 400;
				-webkit-line-clamp: 2;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				overflow: hidden;
				text-overflow: ellipsis;
			}
		}


	}
</style>